﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace ClinicSystem
{
	public static class NativeMethods
	{
		[DllImport("winspool.Drv", CharSet = CharSet.Unicode, SetLastError = true)]
		public static extern bool OpenPrinter(string pPrinterName, out IntPtr phPrinter, ref PRINTER_DEFAULTS pDefault);

		[DllImport("winspool.Drv", CharSet = CharSet.Unicode, SetLastError = true)]
		public static extern bool GetPrinter(IntPtr hPrinter, int dwLevel, IntPtr pPrinter, int dwBuf, out int dwNeeded, out int dwReturned);

		[DllImport("winspool.Drv", CharSet = CharSet.Unicode, SetLastError = true)]
		public static extern bool ClosePrinter(IntPtr hPrinter);
	}

	// PRINTER_DEFAULTS 结构体
	public struct PRINTER_DEFAULTS
	{
		public int DesiredAccess;
		public int Flags;
		public string pDatatype;
		public string pDevMode;
	}

	// PRINTER_INFO_5 结构体
	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
	public struct PRINTER_INFO_5
	{
		public string pPrinterName;
		public string pPortName;
		public string pShareName;
		public string pDriverName;
		public string pComment;
		public string pLocation;
		public IntPtr pDevMode;
		public string pSepFile;
		public string pPrintProcessor;
		public string pDatatype;
		public string pParameters;
		public IntPtr pSecurityDescriptor;
		public int Attributes;
		public int Priority;
		public int DefaultPriority;
		public int StartTime;
		public int UntilTime;
		public int Status;
		public int cJobs;
		public int AveragePPM;
		public string pStatus;
	}
}
